package org.example.pmsystem.service.Impl;

import org.example.pmsystem.entity.Recruit;
import org.example.pmsystem.entity.Resume;
import org.example.pmsystem.mapper.ResumeMapper;
import org.example.pmsystem.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ResumeServiceImpl implements ResumeService {
    @Autowired
    private ResumeMapper resumeMapper;

    @Override
    public List<Recruit> getAllRecruit() {
        return resumeMapper.selectAllRecruit();
    }

    @Override
    public List<Resume> getResumeByUserid(String id) {
        return resumeMapper.selectResumeByUserid(id);
    }

    @Override
    public List<Resume> getResumeByStatus(String status) {
        return resumeMapper.selectResumeByStatus(status);
    }

    @Override
    public List<Resume> getResumeByDep(String dep) {
        return resumeMapper.selectResumeByDep(dep);
    }

    @Override
    public boolean addResume(Resume resume) {
        resume.setUserid(resume.getResPhone());
        if (resumeMapper.checkResume(resume) > 0)
            return false;
        resume.setResStatus("1");
        resumeMapper.insertResume(resume);
        return true;
    }

    @Override
    public boolean updateResume(Resume resume) {
//        resume = modify(resume);
        Resume temp = resumeMapper.selectResumeByResNo(resume.getResNo());
        if (temp.getResStatus().equals(resume.getResStatus())
                && temp.getResStatus().equals("2"))
            resume.setResStatus("1");
        resumeMapper.updateResume(resume);
        return true;
    }

//    private Resume modify(Resume resume) {
//        switch (resume.getResStatus()){
//            case "1":
//                resume.setResStatus("待审核");break;
//            case "2":
//                resume.setResStatus("审核未通过");break;
//            case "3":
//                resume.setResStatus("待筛选");break;
//            case "4":
//                resume.setResStatus("筛选未通过");break;
//            case "5":
//                resume.setResStatus("面试意愿确定");break;
//            case "6":
//                resume.setResStatus("已同意面试");break;
//            case "7":
//                resume.setResStatus("已拒绝面试");break;
//        }
//        return resume;
//    }
}
